from selenium import webdriver
import time

# 实现无可视化操作
chrome_option = webdriver.chrome.options.Options()
chrome_option.add_argument('--headless')
chrome_option.add_argument('--disable-gpu')

# 实现selenium规避检测
option = webdriver.ChromeOptions()
option.add_experimental_option('excludeSwitches', ['enable-automation'])

bro = webdriver.Chrome(executable_path='web_pa\chromedriver.exe', chrome_options=chrome_option, options=option)
bro.get('https://www.baidu.com')

with open('test.html','w',encoding='utf-8') as fp:
    fp.write(bro.page_source)
print('save finish!')